<!DOCTYPE html>
<html>

	<head>
		<title>系统消息</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="../js/bootstrap/css/bootstrap.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="../js/bootstrap/js/bootstrap.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/message.css" />
		<script src="/js/plugins/jrender/jrender.js"></script>

	</head>
<script>
	$(function () {
	    //获取当前用户id
        //从本地session中取出缓存的对象
        var user = JSON.parse(sessionStorage.getItem("user"));
        console.log(user.id);
        //发送get请求查询数据
		$.get("/users/"+user.id+"/systemmessages",{userId:user.id},function (data) {
            console.log(data);
            //渲染到界面中
			$("#messages").renderValues({list:data});
        })
		//绑定清空功能
		$(".deleteAll").click(function () {
            $.ajax({
                url: "/users/"+user.id+"/systemmessages",
                data:user.id,
                type: "DELETE",
                success:function () {
					window.location.reload();
                }
            })
        })
    })
</script>
	<body>
		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="javascript:history.go(-1);">
						<span><i class="fa fa-chevron-left" ></i></span>
					</a>
				</div>
				<div class="col">
					<span>系统</span>
				</div>
				<div class="col deleteAll"></div>
				<div class="col">
					<button class="deleteAll">清空</button>
				</div>
			</div>
		</div>
		<!--当前系统消息-->
		<div id="messages" style=" border:1px solid #cceff5;background:#fafcfd">
			<div class="container systemMsg" render-loop="list">
				<dl class="itemList">
					<dd>
						<p class="fa fa-snapchat">系统消息:</p>
						<p render-html="list.messages"></p>
						<p render-html="list.noticetime"></p>
					</dd>
				</dl>
			</div>
		</div>

	</body>

</html>